package com.stone.framework.basic.param.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import com.stone.framework.core.entity.CommonEntity;
import com.stone.framework.core.util.Strings;

@Entity
@Table(name = "ST_SYSTEM_PARAM")
public class SystemParam extends CommonEntity {

    private static final long serialVersionUID = -4244338564144521072L;

    /**
     * 标识
     */
    @Column(name = "KEY_")
    private String key;

    /**
     * 值
     */
    @Column(name = "VALUE_")
    private String value;

    /**
     * 描述
     */
    @Column(name = "DESC_")
    private String desc;

    /**
     * 类型（是否可用）
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "STATE")
    private State state;

    public static enum State {
        DISABLED("禁用"), ENABLED("启用");

        private String desc;

        private State(String desc) {
            this.desc = desc;
        }

        public String getDesc() {
            return this.desc;
        }

    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getState() {
        return state == null ? null : state.name();
    }

    public void setState(String state) {
        this.state = Strings.isEmpty(state) ? null : State.valueOf(state);
    }

    @Override
    public String toString() {
        return "SystemParam [key=" + key + ", value=" + value + ", desc=" + desc + ", state=" + state + ", "
            + super.toString() + "]";
    }

}
